//! MetaPages.debug.js
//

(function() {

Type.registerNamespace('MetaPages.Classes');

////////////////////////////////////////////////////////////////////////////////
// CssInfo

CssInfo = function CssInfo() {
    /// <field name="_abouters$3" type="String" static="true">
    /// </field>
    /// <field name="_instance$3" type="CssInfo" static="true">
    /// </field>
    /// <field name="_cssProps$3" type="Array" elementType="String" static="true">
    /// </field>
    /// <field name="_btn" type="jQueryObject">
    /// </field>
    /// <field name="_about$3" type="jQueryObject">
    /// </field>
    /// <field name="_metaItem$3" type="String" static="true">
    /// </field>
    CssInfo.initializeBase(this);
    this.element = $("<div class='CssInfo MetaControl'/>").appendTo(document.body).hide().bind('keydown.esc', ss.Delegate.create(this, function(e) {
        Keys.escKey(e, ss.Delegate.create(this, function() {
            this.destroy();
        }));
    }));
    $('body *:not(.MetaControl)').live('mouseover.CssInfo', ss.Delegate.create(this, this._mouseEnter$3));
    $(document.body).bind('mousemove.CssInfo', ss.Delegate.create(this, function(e) {
        if (this.element != null) {
            this.element.css({ top: e.pageY + 34, left: e.pageX - 80 });
        }
    }));
}
CssInfo.ev = function CssInfo$ev(e, btn) {
    /// <param name="e" type="jQueryEvent">
    /// </param>
    /// <param name="btn" type="jQueryObject">
    /// </param>
    if (CssInfo._instance$3 == null) {
        CssInfo._instance$3 = new CssInfo();
        CssInfo._instance$3._btn = btn;
        btn.addClass('Toggled');
    }
    else {
        CssInfo._instance$3.destroy();
    }
}
CssInfo.prototype = {
    _btn: null,
    _about$3: null,
    
    destroy: function CssInfo$destroy() {
        CssInfo._instance$3 = null;
        $('body *:not(.MetaControl)').die('mouseover.CssInfo');
        $(document.body).unbind('mousemove.CssInfo');
        new Await().addDx(ss.Delegate.create(this, function() {
            if (this._about$3 != null) {
                this._about$3.removeClass('Selector');
            }
            if (this.element != null) {
                this.element.remove();
            }
            if (this._btn != null) {
                this._btn.removeClass('Toggled').removeAttr('disabled');
            }
        })).commit();
    },
    
    _mouseEnter$3: function CssInfo$_mouseEnter$3(e) {
        /// <param name="e" type="jQueryEvent">
        /// </param>
        if (this._about$3 != null) {
            this._about$3.removeClass('Selector');
        }
        else {
            this.element.show();
        }
        this._about$3 = $(e.target);
        this.element.empty();
        this._about$3.addClass('Selector');
        var p = this._about$3.offset();
        var ls = this.element;
        var id = (this._about$3.attr('id') != null) ? '#' + this._about$3.attr('id') : '';
        var cn = this._about$3[0].tagName.toUpperCase() + id;
        $("<div class='Item MetaControl'/>").appendTo(ls).html(cn).css('font-weight', 'bold');
        $("<div class='Item MetaControl'/>").appendTo(ls).html('Classes: ' + this._about$3.attr('class').replaceAll('Selector', ''));
        var $enum1 = ss.IEnumerator.getEnumerator(CssInfo._cssProps$3);
        while ($enum1.moveNext()) {
            var n = $enum1.current;
            $("<div class='Item MetaControl'/>").appendTo(ls).html(n + ': ' + this._about$3.css(n));
        }
    }
}


Type.registerNamespace('MetaPages.Clusters');

////////////////////////////////////////////////////////////////////////////////
// MetaCluster

MetaCluster = function MetaCluster() {
    /// <field name="_slideSpeed$3" type="Number" integer="true" static="true">
    /// </field>
    /// <field name="testUserId" type="String" static="true">
    /// </field>
    /// <field name="_instance$3" type="MetaCluster" static="true">
    /// </field>
    /// <field name="_usersSimulated$3" type="Boolean" static="true">
    /// </field>
    /// <field name="testTeller" type="jQueryObject" static="true">
    /// </field>
    /// <field name="_userSelect" type="jQueryObject" static="true">
    /// </field>
    /// <field name="testUsers" type="Object" static="true">
    /// </field>
    /// <field name="_barMargin$3" type="String">
    /// </field>
    /// <field name="_bodyMargin$3" type="String">
    /// </field>
    /// <field name="_testBtn$3" type="jQueryObject">
    /// </field>
    /// <field name="_testSuite$3" type="TestSuite">
    /// </field>
    /// <field name="_userBoxUpdate$3" type="Boolean">
    /// </field>
    MetaCluster.initializeBase(this);
    new Await().loadCss('Scripts/Css/MetaCluster.css').addDx(ss.Delegate.create(this, function() {
        this.element = $("<div class='MetaCluster'/>").appendTo(document.body).hide();
        this._bodyMargin$3 = $(document.body).css('margin-top');
        this._barMargin$3 = (this.element.height() + parseInt(this._bodyMargin$3)) + 'px';
        $('<button/>').appendTo(this.element).html('css').click(function(e) {
            CssInfo.ev(e, $(e.target));
        });
        $("<button class='RefreshBtn'/>").appendTo(this.element).html('refresh').click(function() {
            if (!String.isNullOrEmpty(window.location.search)) {
                window.location.href = window.location.href.split('?')[0];
            }
            else {
                window.location.reload(true);
            }
        });
        MetaCluster._userSelect = $("<select class='UserSelect'/>").appendTo(this.element);
        $('<option/>').appendTo(MetaCluster._userSelect).attr('value', 'live').html('live user');
        var $dict1 = MetaCluster.testUsers;
        for (var $key2 in $dict1) {
            var p = { key: $key2, value: $dict1[$key2] };
            if (Type.canCast(p.value, String)) {
                $('<option/>').appendTo(MetaCluster._userSelect).attr('value', p.value).html(p.key);
            }
        }
        var awx = new Await().waitDx(function() {
            return Master.fbUser != null && ss.isValue(Master.fbUser.id);
        }, 2000);
        if (ss.isValue(Nsb.Storage.getLocal('TestUserId'))) {
            awx.addDx(function() {
                MetaCluster._userSelect.val(Master.profile.get_myId());
            });
        }
        else {
            awx.addDx(function() {
                MetaCluster._userSelect.val('live');
            });
        }
        awx.addDx(ss.Delegate.create(this, function() {
            MetaCluster._userSelect.change(ss.Delegate.create(this, function() {
                this.changeUser(MetaCluster._userSelect.val());
            }));
        })).addDx(function() {
            new DropMenu(MetaCluster._userSelect, { 'Master.alivenessCheck()': 'Aliveness Check' }, function(e, item) {
                eval(item);
            });
        }).commit();
        MetaCluster.testTeller = $("<div class='TestTeller'/>").appendTo(this.element);
        this._testBtn$3 = $("<button class='RunTestsBtn'/>").appendTo(this.element).html('Run Tests').click(function() {
            TestSuite.runMasterSuite();
        });
        var goPage = $("<select class='GoPage'/>").appendTo(this.element).change(function() {
            Master.GoPage($('.MetaCluster .GoPage').val());
        });
        var $dict3 = ThemeBase.oldPages;
        for (var $key4 in $dict3) {
            var p = { key: $key4, value: $dict3[$key4] };
            $('<option/>').attr('value', p.key).html(p.value).appendTo(goPage);
        }
        this.refresh();
        this._slideDown();
    })).commit();
}
MetaCluster.staticRefresh = function MetaCluster$staticRefresh() {
    if (MetaCluster._instance$3 != null) {
        MetaCluster._instance$3.refresh();
    }
}
MetaCluster.ev = function MetaCluster$ev(e) {
    /// <param name="e" type="jQueryEvent">
    /// </param>
    if (MetaCluster._instance$3 == null) {
        MetaCluster._instance$3 = new MetaCluster();
    }
    else {
        if (MetaCluster._instance$3.element.is(':visible')) {
            MetaCluster._instance$3._slideUp();
        }
        else {
            MetaCluster._instance$3._slideDown();
        }
    }
    MetaCluster._instance$3.refresh();
}
MetaCluster._testAuthenticate$3 = function MetaCluster$_testAuthenticate$3() {
    /// <returns type="Boolean"></returns>
    MetaCluster._usersSimulated$3 = !MetaCluster._usersSimulated$3;
    if (ss.isValue(Nsb.Storage.getLocal('TestUserId'))) {
        FbDataStore.prototype.authenticateAw = MetaCluster.testAuthAw;
        Master.testing = true;
    }
    return true;
}
MetaCluster.testAuthAw = function MetaCluster$testAuthAw(awp) {
    /// <param name="awp" type="Await">
    /// </param>
    var id = (Nsb.Storage.getLocal('TestUserId') || MetaCluster.testUsers['Nathan']);
    new Await().addAw(ProfileData.getUserByIdAw, id).addDx(function(aw) {
        var ysr = aw.get_item('result');
        if (ysr != null) {
            Master.profile.set_my(ysr);
        }
    }).commit(awp);
}
MetaCluster.prototype = {
    _barMargin$3: null,
    _bodyMargin$3: null,
    _testBtn$3: null,
    _testSuite$3: null,
    _userBoxUpdate$3: false,
    
    refresh: function MetaCluster$refresh() {
        if (this._testBtn$3 != null) {
            new Await().loadScript('Scripts/MetaTests.debug.js').addDx(ss.Delegate.create(this, function() {
                Test.testUserId = 'TestUserId';
                TestSuite.teller = MetaCluster.testTeller;
                TestSuite.tell(null);
                this._testSuite$3 = TestSuite.getTestSuiteByPage(ThemeBase.currentPageClass);
                var list = (this._testSuite$3 != null) ? this._testSuite$3.testList() : {};
                new TestListMenu(this._testBtn$3, list, ss.Delegate.create(this, function(e, item) {
                    this._testSuite$3.run(item);
                }));
                this._updateUserBox$3(Nsb.Storage.getLocal('TestUserId'));
            })).commit();
        }
    },
    
    _updateUserBox$3: function MetaCluster$_updateUserBox$3(id) {
        /// <param name="id" type="String">
        /// </param>
        if (Master.fbUser == null) {
            window.setTimeout(ss.Delegate.create(this, function() {
                this._updateUserBox$3(id);
            }), 13);
            return;
        }
        if (id != null) {
            new Await().addDx(ss.Delegate.create(this, function() {
                this._userBoxUpdate$3 = true;
            })).addDx(function() {
                MetaCluster._userSelect.val(id);
            }).addDx(ss.Delegate.create(this, function() {
                this._userBoxUpdate$3 = false;
            })).commit();
        }
    },
    
    _slideDown: function MetaCluster$_slideDown() {
        Nsb.Storage.setLocal('MetaBar', true);
        $(document.body).animate({ 'padding-top': this._barMargin$3 }, { duration: 100 });
        this.slideDownAw(Await.get_asyncAw(), 100);
    },
    
    _slideUp: function MetaCluster$_slideUp() {
        Nsb.Storage.setLocal('MetaBar', false);
        $(document.body).animate({ 'padding-top': this._bodyMargin$3 }, { duration: 100 });
        this.slideUpAw(Await.get_asyncAw(), 100);
    },
    
    destroy: function MetaCluster$destroy() {
        MetaCluster._instance$3 = null;
        this._slideUp();
        Nsb.Storage.removeLocal('MetaBar');
        this.element.remove();
    },
    
    changeUser: function MetaCluster$changeUser(id) {
        /// <param name="id" type="String">
        /// </param>
        if (this._userBoxUpdate$3) {
            return;
        }
        if (id === 'live') {
            Nsb.Storage.removeLocal('TestUserId');
            window.location.reload(true);
        }
        else {
            FbDataStore.prototype.authenticateAw = MetaCluster.testAuthAw;
            Master.testing = true;
            Nsb.Storage.setLocal('TestUserId', id);
            Master.GoPage(ThemeBase.currentPageClass);
            this._updateUserBox$3(id);
        }
    }
}


CssInfo.registerClass('CssInfo', Actor);
MetaCluster.registerClass('MetaCluster', Actor);
CssInfo._instance$3 = null;
CssInfo._cssProps$3 = [ 'position', 'top', 'bottom', 'left', 'right', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', 'z-index' ];
MetaCluster.testUserId = 'TestUserId';
MetaCluster._instance$3 = null;
MetaCluster._usersSimulated$3 = MetaCluster._testAuthenticate$3();
MetaCluster.testTeller = null;
MetaCluster._userSelect = null;
MetaCluster.testUsers = { TestUser1: 'TestUser1', TestUser2: 'TestUser2', TestUser3: 'TestUser3', Nathan: '1305946510', Natalie: '793889201', Shallon: '746605760', Kickin: '100002776766039' };
})();

//! This script was generated using Script# v0.7.4.0
